﻿using DotNetDAL.Entity.DbStruct;
using System.Collections.Generic;

namespace DotNetDAL.Connector
{
    class CacheHelper
    {
        /// <summary>
        /// 表结构
        /// </summary>
        private static Dictionary<string, List<DbStructColumnDTO>> tableStruct = new Dictionary<string, List<DbStructColumnDTO>>();
        /// <summary>
        /// 表结构
        /// </summary>
        private static Dictionary<string, string> tableDIC = new Dictionary<string, string>();


        public static void ClearTableStruct()
        {
            tableStruct = new Dictionary<string, List<DbStructColumnDTO>>();
        }
        public static void ClearTableStruct(string table_name)
        {
            if (!tableStruct.ContainsKey(table_name))
            {
                return;
            }
            tableStruct.Remove(table_name);
        }
        public static void SetTableStruct(string table_name, List<DbStructColumnDTO> colList) { 
        if(string.IsNullOrEmpty(table_name) || colList == null|| colList.Count == 0)
            {
                return;
            }
            tableStruct[table_name] = colList;
        }
        public static List<DbStructColumnDTO> GetTableStruct(string table_name)
        {
            return tableStruct.ContainsKey(table_name) ? tableStruct[table_name] : new List<DbStructColumnDTO>();
        }

        public static void ClearTableName()
        {
            tableDIC = new Dictionary<string, string>();
        }
        public static void AddTableName(string table_name)
        {
            if (string.IsNullOrEmpty(table_name) )
            {
                return;
            }
            tableDIC[table_name] = table_name;
        }
        public static bool IsExistTableName(string table_name)
        {
            if (string.IsNullOrEmpty(table_name))
            {
                return false;
            }
            return tableDIC.ContainsKey(table_name);
        }
        





    }
}
